package com.breaktian.demoapp.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.breaktian.assemble.customviews.viewpager.bannerviewpager.AutoBannerView;
import com.breaktian.assemble.customviews.viewpager.bannerviewpager.BannerPagerAdapter;
import com.breaktian.assemble.image.ImageUtils;
import com.breaktian.assemble.utils.LogUtil;
import com.breaktian.demoapp.R;
import com.breaktian.demoapp.provider.BaseProvider;
import com.breaktian.demoapp.ui.base.BaseActivity;
import com.breaktian.demoapp.utils.ToastUtils;

import java.util.Arrays;

public class TestActivity extends BaseActivity {


    private String[] paths = {
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356553&di=b0fac1f26ad69bf0bacbc68de75a2f88&imgtype=0&src=http%3A%2F%2Fpic1.win4000.com%2Fwallpaper%2F7%2F517ce9efb01a2.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356552&di=1c9012fdb10d79bbf612a32641383344&imgtype=0&src=http%3A%2F%2Fimg2.niutuku.com%2Fdesk%2F1207%2F1605%2Fbizhi-1605-11378.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356550&di=71f863d0471ee8c88e11e1c30cde5558&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F4b90f603738da97739e34e0fba51f8198718e3c2.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356549&di=69591b09c9032398a768c2e4245d0317&imgtype=0&src=http%3A%2F%2Fwww.pp3.cn%2Fuploads%2F1304%2F262.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356548&di=58f8861a7759219c4c9db6c3f7291dc6&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F37d12f2eb9389b50baea50778f35e5dde7116efa.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356546&di=0547a9989e526661cfe8617ae5aaf4dc&imgtype=0&src=http%3A%2F%2Fimg1.3lian.com%2F2015%2Fa1%2F25%2Fd%2F168.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497514356554&di=0d17db2db0a11e3bce77392777c8ab74&imgtype=0&src=http%3A%2F%2Fimg3.3lian.com%2F2013%2Fc3%2F74%2Fd%2F69.jpg",
//            "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1498109079&di=2016534635bffc8642adb40d00a74358&imgtype=jpg&er=1&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimgad%2Fpic%2Fitem%2F29381f30e924b89979bc0e1a64061d950a7bf614.jpg",
            "http://pic23.nipic.com/20120806/10504822_150106691000_2.jpg",
            "http://pic.58pic.com/58pic/13/23/37/01958PICjAH_1024.jpg",
            "http://pic37.nipic.com/20140208/12976976_221738337000_2.png",
            "http://pic.58pic.com/58pic/11/95/70/40n58PICPtd.jpg"
    };
    private AutoBannerView autoBannerView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        showToolbar("测试");
        LogUtil.d("测试测试测试");



        findViewById(R.id.button3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //开始
                autoBannerView.startAutoScroll();
            }
        });
        findViewById(R.id.button4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //停止
                autoBannerView.stopAutoScroll();
            }
        });




        //bannerviewpager
        autoBannerView = (AutoBannerView)findViewById(R.id.autoBannerView);
        BannerPagerAdapter<String> bannerPagerAdapter = new BannerPagerAdapter<String>(this, Arrays.asList(paths)){

            @Override
            public void loadImage(ImageView imageView, String url) {
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                ImageUtils.get().loadImage(TestActivity.this,url,imageView);
            }

            @Override
            public String getImageUrl(String object) {
                return object;
            }

            @Override
            public void onClick(String object, View view, int postion) {
                ToastUtils.show("position:"+postion+",object:"+object);

            }
        };
        autoBannerView.setAdapter(bannerPagerAdapter);


    }


    @Override
    protected BaseProvider getProvider() {
        return null;
    }
}
